package br.net.woodstock.tickettoride.web.seam.error;

import java.util.Iterator;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Conversation;

import br.net.woodstock.tickettoride.web.jsf.error.common.AbstractErrorBean;

@Name("errorBean")
@Scope(ScopeType.EVENT)
public class ErrorBean extends AbstractErrorBean {

	private static final long	serialVersionUID	= -2903910914783927112L;

	public boolean isMessages() {
		Iterator<FacesMessage> messages = FacesContext.getCurrentInstance().getMessages();
		if (messages.hasNext()) {
			return true;
		}
		return false;
	}

	@Override
	protected void onEnd() {
		Conversation c = Conversation.instance();
		if (c != null) {
			c.end();
		}
	}

}
